#ifdef HAVE_CONFIG_H 
#include "config.h"
#else 
#error plase use make system to compile, look into INSTALL file for more detals
#endif 

#define DEBUG 1

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include "parser.h"
#include "global.h"
#include "command.h"
#include "external.h"
#include "history.h"

static void version(void)
{
printf(PACKAGE_STRING " University of Strathclyde 2010 \nUnder GNU public licence v2.0 \n");
}


static void usage(void)
{
  printf("cssh whatever swiches will be\n");
  exit(0);
}
  


int main (int argc, char* argv[])
{
  int c;
  char * commandLine = malloc(512);
 

  while ((c = getopt(argc, argv, "?"))!= -1)
    switch(c)
      {
      case '?': usage(); break;
      };
  version();
  
  setGlobals();
  
  if(chdir(CSSH_globals.hom_path)!=0)
    exit(1);
  
  read_from_file(".hist_list");
  init_commands();

    while (1) {
    printf("%s > ", CSSH_globals.cur_path);
    fgets(commandLine, 512, stdin);
    if(strlen(commandLine) == 1) continue;

    
    switch(run_command(commandLine))
      {
	/*finished fine*/
      case 0: break; 
	/*error */
      case -1: 
	printf("Error happend :(\n");
	break;
      }

    }  
    
    return 0;
}
    
